package com.talent.web.controller;

import lombok.Data;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: hszhou
 * @Date: 2025/5/12 9:02
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
@Slf4j
@RestController
@RequestMapping("/mqtt")
public class MqttController {


    @PostMapping("/login")
    public ResponseEntity login(@RequestBody User user){
        log.info("post json提交[{}]",user);
        if(user.getUsername().equals("adminPost") && user.getPassword().equals("adminPost")){
            log.info("post json 成功");
            return ResponseEntity.ok().build();
        }else{
            log.info("post json 失败");
            return ResponseEntity.status(401).build();
        }

    }
    @GetMapping("/login/test")
    public ResponseEntity loginTest(User user){
        log.info("get 提交[{}]",user);
        if(user.getUsername().equals("adminGet") && user.getPassword().equals("adminGet")){
            log.info("get 成功");
            return ResponseEntity.ok().build();
        }else{
            log.info("get 失败");
            return ResponseEntity.status(401).build();
        }

    }
    @PostMapping("/login/test")
    public ResponseEntity loginFrom(User user){
        log.info("post 表单 提交 [{}]",user);
        if(user.getUsername().equals("adminForm") && user.getPassword().equals("adminForm")){
            log.info("post form 成功");
            return ResponseEntity.ok().build();
        }else{
            log.info("post form 失败");
            return ResponseEntity.status(401).build();
        }

    }




}
@Data
@ToString
class User{
    private String username;
    private String password;
}